﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using org.jivesoftware.util;
using CryptAPI;
using Emploees;

using Npgsql;

//using System.Security.Cryptography;

namespace Emploees
{
    static class Program
    {
        static public  Form passwordform;
        static public Form worktimeform;
        static public Form timemanage;
        static public bool flag;
        /// <summary>
        /// Главная точка входа для приложения.
        /// </summary>
        [STAThread]
        static void Main()
        {
            flag = false;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
          
            NpgsqlConnection conn = Global_variables.connecttodb();
            conn.Open();
            passwordform = new PasswordForm();
            //worktimeform = new WorkTimeForm();
            //Application.Run(passwordform);
            passwordform.ShowDialog();
            //if (flag==true) worktimeform.ShowDialog();

           
            /*
            while (!flag)
            {
                if (passwordform.Created != false) passwordform.Show();
                
            }
            MessageBox.Show("QQQQQQQQQQQQQQQQQ");

           /*
            Configuration config = ConfigurationManager.OpenExeConfiguration("/");
            string oldValue = config.AppSettings.Settings["SomeKey"].Value;
            config.AppSettings.Settings["SomeKey"].Value = "NewValue";
            config.Save(ConfigurationSaveMode.Modified);
*/

            //NpgsqlConnection conn = new NpgsqlConnection("Server=10.1.0.241;Port=5432;User Id=postgres;Password=system;Database=Staff;");
            
            
            //UnixCrypt asd = new UnixCrypt();
            
            //MessageBox.Show(UnixCrypt.Crypt("md5", "password"));
           
            /*
            Blowfish algo = new Blowfish("04B915BA43FEB5B6");
            string encryptedTxt = algo.encryptString("password");
            Blowfish b = new Blowfish("04B915BA43FEB5B6");
            MessageBox.Show(encryptedTxt);
           */
            //string plainText = "password";
            //string cipherText = b.Encrypt_ECB(plainText);
            
            //MessageBox.Show(cipherText);
            //MessageBox.Show(encryptedTxt);
            //string decryptedTxt = algo.decryptString(encryptedTxt);
            CryptServiceProvider provider = new CryptServiceProvider();
            HashAlgorithm bf = provider.GetCryptServiceProvider(Algorithm.BF);
            //string salt = "Averyveryveryveryverylongstring";
            string salt = "$2a$06$T/XEb77ygpFn5MGskECJdu";
            MessageBox.Show(bf.Encrypt("password", salt));
            
            
            Application.Run(new WorkTimeForm());
        }
        
    }

    
}
